package com.happy016.receiver;

import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

@Component
public class HelloReceiver {

    private int count = 0;

    @RabbitListener(queues = "hello")
    public void receiverHello(String hello){
        System.out.println("Now: "+ new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())+
                "! Receiver "+(++count)+" from hello,content: "+ hello);
    }

    @RabbitListener(queues = "hello")
    public void receiverHello2(String hello2){
        System.out.println("Now: "+ new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())+
                "! Receiver "+(++count)+" from hello2,content: "+ hello2);
    }

    @RabbitListener(queues = "test")
    public void receiverTest(String test){
        System.out.println("Now: "+ new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())+
                "! Receiver "+(++count)+" from test,content: "+ test);
    }
}
